home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCglobals.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-09
|
9KB
|
245 lines
/* begincopyright
Copyright (c) 1988,1990 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
Parts of this software were derived from code bearing the copyright notice:
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
This material may be freely distributed, provided this notice is retained.
This material is provided as is, with no warranty expressed or implied.
Use at your own risk.
endcopyright */
# include "xr/GCPrivate.h"
# include "xr/GCVirtualDirty.h"
/*
* Boehm, January 15, 1991 4:23:14 pm PST
*/
/* Initialized variable declarations for garbage collector globals. Needed */
/* to ensure that they all end up in contiguous memory in the data segment */
/* rather than in separate common blocks. */
/* Many are set to their real initial values by executable code. */
word GC_first_global = 0;
/* Public variables. May be altered by client. */
bool GC_dont_gc = FALSE; /* inhibit collection */
bool GC_fix_heap_size = FALSE; /* inhibit heap expansion */
long GC_non_gc_bytes = 0; /* Number of bytes declared to be uncollectable. */
bool GC_markCarefully = FALSE; /* Full collections should minimize working */
/* set rather than cpu time. */
bool GC_safe_to_gc_print = FALSE; /* OK to produce messages with xr_printf */
bool GC_ok_to_panic = TRUE; /* OK to call XR_panic if things go completely */
/* haywire. Dont turn this off without a VERY */
/* good reason. */
unsigned GC_partial_gc_allocs = 0;
unsigned GC_full_gc_allocs = FULL_GC_ALLOCS;
unsigned GC_free_mem_ratio = FREE_MEM_RATIO; /* Heap expansion factor */
/* Public variables. Read only for the client. Set by collector. */
char * GC_heapstart = 0; /* A lower bound on all heap addresses */
/* Known to be HBLKSIZE aligned. */
char * GC_heaplim = 0; /* 1 + last address in heap */
long GC_heapsize = 0; /* Heap size in bytes */
char * GC_sys_mem_end = 0; /* 1 + end of memory allocated from system. */
/* May differ from GC_heaplim if other */
/* allocation, e.g. for block headers */
/* is going on. */
long GC_mem_found = 0; /* Number of words reclaimed since start of last */
/* collection. Approximate. */
long GC_mem_freed = 0; /* Number of longwords explicitly */
/* freed since last garbage collection. */
long GC_composite_in_use = 0; /* Number of longwords in accessible composite */
/* objects. */
long GC_atomic_in_use = 0; /* Number of longwords in accessible atomic */
/* objects. */
/* Both of the above numbers are good upper */
/* bounds. */
long GC_objects_in_use = 0; /* Number of live objects found during last */
/* collection. */
bool GC_running_exclusive = FALSE; /* True if a single process has taken */
/* over all the processors. */
long GC_markfaults = 0; /* The number of page faults that occurred during the */
/* last mark phase. */
long GC_max_markfaults = 0; /* The recent max of above */
long GC_gc_no = 0; /* How many times have we collected? */
bool GC_demand_collection = FALSE; /* Someone wants a collection done */
long GC_tenure_count = 0; /* Number of scanned, tenured blocks */
unsigned GC_words_allocd = 0; /* Number of words allocated since last */
/* collection. */
unsigned GC_words_allocd_before_gc = 0;
/* Words allocated up to last garbage */
/* collection. The sum of this and the */
/* preceding variable is the total */
/* number of words allocated since the */
/* beginning of the world. */
unsigned GC_objects_allocd = 0; /* Number of objects allocated since last */
/* collection. */
unsigned GC_objects_allocd_before_gc = 0; /* Objects allocated up to last */
/* garbage collection. */
int GC_n_maps_cached = 0;
/* The number of heap block maps currently in the cache */
int GC_words_at_full_gc = 0; /* words accessible after full gc */
int GC_composite_at_full_gc = 0; /* composite words accessible after full gc */
/* Private to the collector: */
unsigned GC_mode = 0;
unsigned GC_requested_mode = 0;
struct hblk * GC_hblkfreelist = (struct hblk *)0;
# ifdef PRINTSTATS
long GC_reclaim_count = 0; /* Number of reclaimed small object blocks */
# endif
long GC_my_composite_in_use = 0;
long GC_my_atomic_in_use = 0;
long GC_my_objects_in_use = 0;
long GC_sp_at_alloc = 0; /* approximate stack pointer at allocator */
/* invocation. */
# ifdef SEPARATE_HEADERS
hdr * GC_hdr_fl = HDR_NIL; /* Free list for heap block headers */
# endif
/* Monitor locks for allocation, tracing, and allocator callback */
/* respectively. */
struct XR_MLRep GC_allocate_ml = {0};
struct XR_MLRep GC_alloc_callback_ml = {0};
/* Garbage collector callbacks: */
RegisterGCCallbackType GC_callBackBefore = (RegisterGCCallbackType)0;
RegisterGCCallbackType GC_callBackAfter = (RegisterGCCallbackType)0;
RegisterGCCallbackType GC_callBackDuring = (RegisterGCCallbackType)0;
XR_Pointer GC_callBackBeforeClientData = (XR_Pointer)0;
XR_Pointer GC_callBackAfterClientData = (XR_Pointer)0;
XR_Pointer GC_callBackDuringClientData = (XR_Pointer)0;
/* Mark stack: */
word * GC_mark_stack_bottom = (word *)0;
word * GC_mark_stack_top = (word *)0;
/* List of root segments for marking: */
long GC_num_data = 0; /* Number of entries in GC_data_list */
struct data_list GC_data_list[MAX_DATA_LIST] = {{0}};
/* List of all data areas that must be treated as roots */
/* by the collector. */
/* Object free lists */
struct obj * GC_aobjfreelist[MAXOBJSZ+1] = {(struct obj *)0};
struct obj * GC_objfreelist[MAXOBJSZ+1] = {(struct obj *)0};
/* Map of block use. */
char GC_hblkmap[MAP_SIZE] = {0};
/* Pages with known false references */
# ifdef BLACK_LIST
char GC_blacklist[MAP_SIZE] = 0; /* Nonzero ==> false reference */
# endif
/* Virtual dirty bit stuff. */
/* Private arrays for GCVirtualDirty.c. Must be inside the area */
/* delimited by GC_first_global and GC_last_global, and separated */
/* from either end by at least a page, so they don't get protected. */
char VD_Status[VDS_SIZE] = {0};
char VD_Clients[VDS_SIZE] = {0};
/* Other virtual dirty bit related variables that must be here. */
int XR_explicitly_unprotected_pages = 0;
int XR_wasted_preparation_calls = 0;
int XR_protection_violations = 0;
char * VD_base = 0; /* beginning of range for which above tables are kept. */
XR_VDBuf vDCurrentBuf = 0; /* Current buffer for XR_VDOp. */
/* Lists of blocks waiting to be reclaimed */
struct hblk * GC_reclaim_list[MAXOBJSZ+1] = {(struct hblk *)0};
struct hblk * GC_areclaim_list[MAXOBJSZ+1] = {(struct hblk *)0};
/* Number of reclaim list invalidations */
unsigned long GC_reclaim_inval_counter = 0;
/* Maps of heap block layouts. */
char * GC_obj_map[MAXOBJSZ+1] = {(char *)0};
# ifdef RESTRICTED_INTERIOR_POINTERS
char GC_valid_offsets[MAX_OFFSET+1] = {0};
# endif
# ifdef SEPARATE_HEADERS
/* List of all header areas. Should be private but needs */
/* to not be scanned. */
# define MAX_HEADER_AREAS 256
struct hdr_area {
char * ha_start;
char * ha_end;
} GC_header_areas[MAX_HEADER_AREAS] = {{0,0}};
/* Header table. */
struct hblkhdr * GC_headers[MAP_SIZE] = {(struct hblkhdr *)0};
# endif
char GC_map_cache[MAP_CACHE_SZ][HBLKSIZE/BYTES_PER_WORD] = {{0}};
/* Space used to hold GC_obj_map maps */
# ifdef MERGE_SIZES
long GC_size_map[MAXOBJSZ+1] = {0};
# endif
char GC_dirty_bits[MAP_SIZE + (MAX_DATA_SIZE/HBLKSIZE)] = {0};
word GC_last_global = 0;
/* Stuff below here is private to the collector, but should be used as a */
/* root for marking. */
/* List of finalizable objects: */
# ifdef FINALIZE
XR_FinalizationHandle GC_finalizeListHead = (XR_FinalizationHandle)0;
# endif /* FINALIZE */
struct uncollectable_structure * GC_pin_head =
(struct uncollectable_structure *) 0;
/* Head of list of uncollectable objects. */